function time() {
    var today = new Date();
    var hou;
    var time;
    var day;
    if (today.getHours() < 12 && today.getHours() >= 0) {
        hou = today.getHours();
        time = "AM";
    } else if (today.getHours() <= 24 && today.getHours() >= 12) {
        if (today.getHours() == 12) {
            hou = 12;
        } else {
            hou = today.getHours() - 12;
        }
        //hou = today.getHours() - 12;
        time = "PM";
    }
    var d = today.getDay();
    if (d == 0) {
        day = "日";
    } else if (d == 1) {
        day = "一";
    } else if (d == 2) {
        day = "二";
    } else if (d == 3) {
        day = "三";
    } else if (d == 4) {
        day = "四";
    } else if (d == 5) {
        day = "五";
    } else if (d == 6) {
        day = "六";
    }

    var fen; //= today.getMinutes();
    if (today.getMinutes() < 10) {
        fen = "0" + today.getMinutes();
    } else {
        fen = today.getMinutes();
    }
    var miao; //= today.getMinutes();
    if (today.getSeconds() < 10) {
        miao = "0" + today.getSeconds();
    } else {
        miao = today.getSeconds();
    }
    document.getElementById("clock").innerHTML = (today.getFullYear() + "年" + (today.getMonth() + 1) + "月" + today.getDate() + "日 " + hou + ":" + fen + ":" + miao + "  " + time + " 星期" + day);
}

var myTime = setInterval("time()", 1000);